
#include "iostream"
using namespace std;
#include "vector"
int countPairs(vector<int>&nums,int low,int high){
    int t=0;
    int max=nums[0];
    //寻找最大值
    for (int k = 1; k <nums.size(); ++k) {
        if (max<nums[k])
            max=nums[k];
    }
    int find=1;
    while(find<=max){
        find*=2;
    }
//    cout<<find<<endl;
    for (int i = 0; i <nums.size()-1; ++i) {
        for (int j = i+1; j <nums.size(); ++j) {
            int sum=nums[i]+nums[j];
            if (sum>=find){
                sum=abs(nums[i]-nums[j]);
                cout<<sum<<endl;
                if (sum>=low&&sum<=high){
                    t++;
                    cout<<"("<<i<<","<<j<<"):sum="<<nums[i]+nums[j]<<endl;
                }

            }else{
                if (sum>=low&&sum<=high){
                    t++;
                    cout<<"("<<i<<","<<j<<"):sum="<<nums[i]+nums[j]<<endl;
                }
            }
        }
    }
    return t;
}